home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / tde31.zip / CFGHELP.C < prev    next >
C/C++ Source or Header  |  1993-08-29  |  2KB  |  95 lines

  1. /*
  2.  * This module contains all the routines needed to create a new help
  3.  * screen.  The new help screen is read from a file which must exist before
  4.  * executing this routine.
  5.  *
  6.  * Program Name:  tdecfg
  7.  * Author:        Frank Davis
  8.  * Date:          October 5, 1991
  9.  */
  10.  
  11. #include <io.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15.  
  16. #include "tdecfg.h"
  17. #include "cfghelp.h"
  18.  
  19. extern struct vcfg cfg;
  20. extern FILE *tde_exe;                  /* FILE pointer to tde.exe */
  21. extern long help_offset;
  22.  
  23. static WINDOW *w_ptr;
  24.  
  25.  
  26. /********    EXTREMELY IMPORTANT   ************/
  27. /*
  28.  * If you modify tde, it is your responsibility to find the offset of
  29.  * the help screen in your new executable, tde.exe.
  30.  *
  31.  */
  32.  
  33.  
  34.  
  35. /*
  36.  * Name:    tdehelp
  37.  * Date:    October 1, 1991
  38.  * Notes:   Set up most of the window global variables.
  39.  */
  40. void tdehelp( void )
  41. {
  42. int c;
  43. int i;
  44. char line[200];
  45. char out_line[82];
  46. char fname[82];
  47. char *rc;
  48. FILE *help_file;                  /* FILE pointer to help screen */
  49. long offset;
  50.  
  51.  
  52.    cls( );
  53.    show_box( 0, 0, help_screen, NORMAL );
  54.    xygoto( 42, 14 );
  55.    c = getkey( );
  56.    while (c != '1' && c != '2')
  57.       c = getkey( );
  58.    if (c == '1') {
  59.       puts( "" );
  60.       puts( "" );
  61.       puts( "" );
  62.       puts( "Enter file name that contains new help screen :" );
  63.       gets( fname );
  64.       if ((c = access( fname, EXIST )) != 0) {
  65.          puts( "\nFile not found.  Press any key to continue." );
  66.          c = getkey( );
  67.          cls( );
  68.          return;
  69.       } else if ((help_file = fopen( fname, "r" )) == NULL ) {
  70.          puts( "\nCannot open help file.  Press any key to contine." );
  71.          c = getkey( );
  72.          cls( );
  73.          return;
  74.       }
  75.       offset = help_offset + 8;
  76.       rc = fgets( line, 100, help_file );
  77.       for (c=0; c<25 && rc != NULL; c++) {
  78.          memset( out_line, '\0', 82 );
  79.          for (i=0; i<80 && line[i] != '\n'; i++)
  80.              out_line[i] = line[i];
  81.          fseek( tde_exe, offset, SEEK_SET );
  82.          fwrite( out_line, sizeof( char ), 81, tde_exe );
  83.          offset += 81;
  84.          rc = fgets( line, 100, help_file );
  85.       }
  86.       fclose( help_file );
  87.       puts( "" );
  88.       puts( "" );
  89.       puts( "" );
  90.       puts( "New help screen successfully installed.  Press any key to continue." );
  91.       c = getkey( );
  92.    }
  93.    cls( );
  94. }
  95.